var now = {
    template: '#now',
    data(){
        return{
            myUrl:'http://api.zgtxcj.com/txcjapi/',
            allNew:[],
            newnum:1,
            respBox:[]
        }
    },
    methods: {
        toNotice(){
            this.$router.forward({path:'/Notice'})
        },
        toReference(){
            this.$router.forward({path:'/Reference'})
        },
        tofor(){
            // this.$router.push({path:'/infor '});
            this.$router.forword({path:'/'})
        },
        toInfor(){
            // this.$router.push({path:'/infor '});
            this.$router.forward({path:'/infor'})
        },
        getNews:function(){
            var self = this;
            reqwest({
                url:self.myUrl+'indexplate/?tag=4&p_id='+self.newnum,
                method:'get',
                type:'json',
                success:function (resp) {
                    for(var h in resp){
                        var newDate=new Date();
                        newDate.setTime(resp[h]['nc_time'] *1000);
                        resp[h]['nc_time']=newDate.toLocaleDateString();
                        if(resp[h]['nc_image']!=null){
                            resp[h]['nc_image']=resp[h]['nc_image'].replace(/\/upload/,'');
                            self.respBox.push(resp[h])
                        }
                    }
                    self.clickMore()
                }
            })
        },
        clickMore(){
            var self=this;
            $('.see_more').click(function () {
                self.newnum++;
                self.getNewNews();
            })
        },
        getNewNews:function(){
            var self = this;
            reqwest({
                url:self.myUrl+'indexplate/?tag=4&p_id='+self.newnum,
                method:'get',
                type:'json',
                success:function (resp) {
                    for(var h in resp){
                        var newDate=new Date();
                        newDate.setTime(resp[h]['nc_time'] *1000);
                        resp[h]['nc_time']=newDate.toLocaleDateString();
                        if(resp[h]['nc_image']!=null){
                            resp[h]['nc_image']=resp[h]['nc_image'].replace(/\/upload/,'');
                            self.respBox.push(resp[h])
                        }
                    }
                }
            })
        },
        gowhere() {
//                window.localStorage.setItem('token','')
            var tok=window.localStorage.getItem('token');
            if(tok!=''){
                // this.$router.push({path:'/my'});
                this.$router.forward({path:'/my'})
            }else {
                // this.$router.push({path:'/login'});
                this.$router.forward({path:'/login'})
            }
        },
        lun(){
           $(function () {
               setTimeout(lunbo,1000)
               function lunbo() {
                   var mySwiper = new Swiper ('.swiper-container', {
                       direction: 'horizontal',
                       loop: true,
                       autoplay: 3000,
                       autoplayDisableOnInteraction : false,
                       // 如果需要分页器
                       pagination: '.swiper-pagination',
                       paginationClickable: true
                   })
               }
           })
        }
    },
    beforeMount(){
        this.lun();
        this.getNews();
    }
};
var my={
    template:'#my',
    data(){
        return{
            myUrl:'http://api.zgtxcj.com/',
            phone:localStorage.getItem('phone'),
            userid:localStorage.getItem('uid'),
            uname:localStorage.getItem('username'),
            user_na:'',
            zuan_item:[]
        }
    },
    methods: {
        getMe(){
            var self = this;
            reqwest({
                url:'http://api.zgtxcj.com/txcjapi/user_mess/?id='+self.userid,
                method:'get',
                type:'json',
                success(resp){
                    self.user_na=resp['U_Nname'];
                    // console.log(resp)
                }
            })
        },
        getZuan(){
            var self = this;
            reqwest({
                url: 'http://api.zgtxcj.com/txcjapi/udia/?tag=dia&u_id='+self.userid,
                method: 'get',
                type: 'json',
                success(resp){
                    //console.log(resp)
                    for(var k in resp){
                          if(resp[k]['d_image'].indexOf('|')!=-1){
                                resp[k]['d_image']=resp[k]['d_image'].split('|')[0]
                          }
                   }
                    self.zuan_item=resp;
                }
            })
        },
        toNotice(){
            this.$router.back({path:'/Notice'})
        },
        toReference(){
            this.$router.back({path:'/Reference'})
        },
        toIndex(){
            this.$router.back({path:'/'})
        },
        toZi(){
            this.$router.forward({path:'/myzi'})
        },
        toZuan(){
            this.$router.forward({path:'/zuanshi'})
        },
        toZuanGuan(){
            this.$router.forward({path:'/zuanguan'})
        },
        toMy(){
            this.$router.forward({path:'/my'})
        },
        toTabs(){
            this.$router.forward({path:'/tabs'})
        },
        toChannel(){
             this.$router.forward({path:'/channel'})
        },
        tuichu(){
            window.localStorage.setItem('token','');
            this.$router.forward({path:'/login'})
        },
        pan(){
            //history.go(0) 
            var self = this;
            var ua = window.navigator.userAgent.toLowerCase();
            if(ua.match(/MicroMessenger/i) == 'micromessenger'){
                self.puanTag="wx";
                localStorage.setItem('puanTag','wx')
            }else{
                self.puanTag="google";
                localStorage.setItem('puanTag','google')
            }
            reqwest({
                url:'http://api.zgtxcj.com/straapi/login/',
                method:'get',
                type:'json',
                data:{
                    username:localStorage.getItem('phone'),
                    token:localStorage.getItem('token'),
                    tag:self.puanTag
                },
                success:function(resp){
                    if(resp!=false&&resp!=true){
                        window.localStorage.setItem('token',resp);
                        //this.$router.forward({path:'/my'})
                    }else {
                        //self.$router.forward({path:'/my',redirect:'/login'})
                        self.$router.forward({path:'/login'})
                        //window.location.href='http://wx.zgtxcj.com/gongzhonghao/index.html#/login';
                    }
                }
            })
            // if(tok==''||tok==null){
            //     window.location.href='http://wx.zgtxcj.com/gongzhonghao/index.html#/login';
            //     // this.$router.forward({path:'/login'})
            // }else {
            //     this.$router.forward({path:'/my'})
            // }
        }
    },
    beforeMount(){
        this.getZuan();
        this.getMe();
        this.pan()
    }
};
var Reference={
    "template":'#Reference',
    data(){
        return{

        }
    },
    methods:{
        toIndex(){
            this.$router.back({path:'/'})
        },
        toMy(){
            this.$router.forward({path:'/my'})
        },
        toNotice(){
            this.$router.forward({path:'/Notice'})
        }
    },
    beforeMount(){

    }
};
var Notice={
    "template":'#Notice',
    data(){
        return{

        }
    },
    methods:{
        toMy(){
            this.$router.forward({path:'/my'})
        },
toIndex(){
            this.$router.back({path:'/'})
        },
        toReference(){
            this.$router.back({path:'/Reference'})
        },
    }
};
var infor={
    template: '#infor',
    data(){
        return{
            thisnew:[],
            thisnid:localStorage.getItem('nid')
        }
    },
    methods:{
        getnowNew(){
            var self=this;
            reqwest({
                url:'http://api.zgtxcj.com/txcjapi/newsdetail/?tag=second&id='+self.thisnid,
                method:'get',
                type:'json',
                success(resp){
                    resp.nc_content=resp.nc_content.replace(/&quot;/g,'').replace(/&amp;nbsp;/g,'').replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/<img/g,'{img').replace(/<p/g,'{p').replace(/<\/?.+?>/g,'').replace(/{p/g,'<p').replace(/{img/g,'<img').replace(/src=/g,'width=100% src=http://www.zgtxcj.com/').replace(/(\s{2,10})/g,'');
                    var newDate=new Date();
                    newDate.setTime(resp['nc_time'] *1000);
                    resp['nc_time']=newDate.toLocaleDateString();
                    resp.nc_image=resp.nc_image.replace(/\/upload/,'');
                    self.thisnew=resp
                }
            })
        },
        goNow(){
            this.$router.back({path:'/'})
        }
    },
    beforeMount(){
        this.getnowNew()
    }
};
var xieyi={
    template:'#xieyi',
    data(){
          return{
            
          }
    },
    methods:{
        goNow(){
            this.$router.back({path:'/tijiao'})
        }
    }
};
var zuanguan={
    template:'#zuanguan',
    data(){
        return{
            myUrl:'http://api.zgtxcj.com/',
            zuanAll:[],
            uid:localStorage.getItem('uid')
        }
    },
    methods:{
        getZuan(){
            var self=this;
            reqwest({
                url:'http://api.zgtxcj.com/txcjapi/udia/?tag=dia&u_id='+self.uid,
                method:'get',
                type:'json',
                success(resp){
                    for (var u in resp){
                        resp[u]['dpt_endtime']=resp[u]['dpt_endtime'].substring(0,10);
                         if(resp[u]['d_image'].indexOf('|')!=-1){
                                resp[u]['d_image']=resp[u]['d_image'].split('|')[0]
                          }
                    }
                    self.zuanAll=resp
                }
            })
        },
        getTuisong(){
            this.$router.forward({path:'/tui'});
        },
        goNow(){
            this.$router.back({path:'/my'})
        },
        pan(){
            //history.go(0) 
            var self = this;
            var ua = window.navigator.userAgent.toLowerCase();
            if(ua.match(/MicroMessenger/i) == 'micromessenger'){
                self.puanTag="wx";
                localStorage.setItem('puanTag','wx')
            }else{
                self.puanTag="google";
                localStorage.setItem('puanTag','google')
            }
            reqwest({
                url:'http://api.zgtxcj.com/straapi/login/',
                method:'get',
                type:'json',
                data:{
                    username:localStorage.getItem('phone'),
                    token:localStorage.getItem('token'),
                    tag:self.puanTag
                },
                success:function(resp){
                    if(resp!=false&&resp!=true){
                        window.localStorage.setItem('token',resp);
                    }else {
                        console.log(localStorage.getItem('token'))
                        self.$router.forward({path:'/login'})
                        //window.location.href='http://wx.zgtxcj.com/gongzhonghao/index.html#/login';
                    }
                }
            })
        }
    },
    beforeMount(){
        this.getZuan();
        this.pan();
    }
};
var myzi={
    template:'#myzi',
    data(){
        return{
            myUrl:'http://api.zgtxcj.com/',
            userid:localStorage.getItem('uid'),
            user_mess:[]
        }
    },
    methods:{
        getMess(){
            var self = this;
            reqwest({
                url:'http://api.zgtxcj.com/txcjapi/user_mess/?id='+self.userid,
                method:'get',
                type:'json',
                success(resp){
                    self.user_mess=resp;
                    localStorage.setItem('qudao',resp.U_Number);
                    localStorage.setItem('username',resp.U_Nname)
                }
            })
        },
        goNow(){
            this.$router.back({path:'/my'})
        },
        toChange(){
            this.$router.forward({path:'/change'})
        },
    },
    beforeMount:function(){
        this.getMess();
    }
};
var change={
    "template":'#change',
    data(){
        return{
            passOld:'',
            passNew:'',
            passNew1:''
        }
    },
    methods:{
        goNow(){
            this.$router.back({path:'/myzi'})
        },
        showCustomPopup() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">两次密码不一致</p>', options)

            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
        showCustomPopup1() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">修改成功</p>', options)

            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
        showCustomPopup2() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">原密码错误</p>', options)

            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
        changePass(){
            var self = this;
            if(self.passNew==self.passNew1){
                reqwest({
                    url:'http://api.zgtxcj.com/mobile/updatepass/',
                    method:'post',
                    type:'json',
                    data:{
                        uid:localStorage.getItem('uid'),
                        oldPassword:self.passOld,
                        password:self.passNew1,
                    },
                    success(resp){
                        if(resp['result']=='ok'){
                            self.showCustomPopup1();
                            self.passOld='';
                            self.passNew='';
                            self.passNew1='';
                            self.$router.back({path:'/myzi'})
                        }else {
                            self.showCustomPopup2();
                            self.passOld='';
                        }
                    }
                })
            }else {
                self.passNew='';
                self.passNew1='';
                self.showCustomPopup()
            }
        }
    }
};
var tui={
    template:'#tui',
    data(){
        return{
            zuanId:localStorage.getItem('tuiid'),
            zuanChan:[],
            zuanNa:[],
            zuanFu:[]
        }
    },
    methods:{
        goNow(){
            this.$router.back({path:'/zuanguan'})
        },
        getZuanN(){
            var self = this;
            reqwest({
                url:'http://api.zgtxcj.com/txcjapi/indiamonds/?tag=diamonds&id='+self.zuanId,
                method:'get',
                type:'json',
                success(resp){
                    self.zuanNa=resp;
                }
            })
        },
        getTuiso(){
            var self = this;
            reqwest({
                url:'http://api.zgtxcj.com/txcjapi/indiamonds/?tag=diapro&id='+self.zuanId,
                method:'get',
                type:'json',
                success(resp){
                    for (var k in resp){
                        resp[k]['product']['p_image']= resp[k]['product']['p_image'].split('|')[0];
                        if(resp[k]['dp_tag']==1){
                            self.zuanChan.push(resp[k]);
                        }
                    }
                    self.tuiOver();
                }
            })
        },
        tuiOver(){
            this.$nextTick(function () {
                if($('.zuan_song').height()<($('html').height()-$('.zuan_guan_t').height()-100)){
                    $('.zuan_guan').height($('body').height())
                }else {
                    $('.zuan_guan_ti').css('position','relative')
                }
            })
        },
        now(){
            var self=this;
            reqwest({
                url:'http://api.zgtxcj.com/mobile/udiaserver/',
                methon:'gett',
                type:'json',
                data:{
                    did:localStorage.getItem('tuiid'),
                    uid:localStorage.getItem('uid'),
                    pid:localStorage.getItem('tid')
                },
                success(resp){

                    self.zuanFu=[];
                    resp['message']['p_image']=resp['message']['p_image'].split('|')[0];
                    if(resp['message']['p_serverdetail']==null){

                    }else {
                        resp['message']['p_serverdetail']=resp['message']['p_serverdetail'].replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&quot;/g,'').replace(/&amp;nbsp;/g,'').replace(/src=/g,'src=http://www.zgtxcj.com').replace(/(\s{2,80})/g,'<br>').replace(/nbsp;/g,'').replace(/<br>/g,'').replace(/<img/g,'<img width=100% height=100% onclick=javascript:window.open(this.src);').replace(/alt=/g,'&nbsp;');
                    };
                    self.zuanFu=resp['message'];
                    self.getClick();
                }
            });
        },
        getClick(){
            this.$nextTick(function () {
                // $('.zuan_song_box li').click(function () {
                $('.zuan_fix_bg').css('display','block');
                $('.zuan_fix').css('display','block');
                // });
            })
        },
        close(){
            $('.zuan_fix_bg').css('display','none');
            $('.zuan_fix').css('display','none');
        },
    },
    beforeMount(){
        this.getZuanN();
        this.getTuiso();
    }
};
var login={
    template:'#login',
    data(){
        return{
            // myUrl:'http://fapp.zgtxcj.com:88/',
            myUrl:'http://api.zgtxcj.com/',
            phone:'',
            password:'',
            tok:'',
            uesrid:'',
            puanTag:'',
        }
    },
    methods:{
        goNow(){
            window.localStorage.setItem('token','');
            this.$router.back({path:'/'})
        },
        toSign(){
            this.$router.forward({path:'/sign'})
        },
        toForget(){
            this.$router.forward({path:'/forget'})
        },
        postData() {
            var self = this;
            $loading.show('登录中..');
            var ua = window.navigator.userAgent.toLowerCase(); 
            if(ua.match(/MicroMessenger/i) == 'micromessenger'){ 
                  self.puanTag="wx"
            }else{ 
                   self.puanTag="google"
            } 
            reqwest({
                url : self.myUrl + "straapi/login/",
                method: "post",
                type: "json",
                data:{
                    username: self.phone,
                    passwd: self.password,
                    tag:self.puanTag,
                },
                success:function(resp) {
                    if(resp==false){
                        $loading.hide();
                        $toast.show('密码错误');
                    }else {
                        self.tok=resp['TOKEN'];
                        self.userid=resp['U_ID'];
                        window.localStorage.setItem('token',self.tok);
                        window.localStorage.setItem('uid',self.userid);
                        window.localStorage.setItem('phone',self.phone);
                        $loading.hide();
                        self.$router.forward({path:'/my'});
                        self.aja();
                    }
                },
                error:function () {
                    $loading.hide();
                    self.showCustomPopup()
                }
            });
        },
        showCustomPopup() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">密码错误或者该帐号未注册</p>', options);
            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
        aja(){
            var self=this;
            reqwest({
                url:'../../code.php',
                method:'post',
                type:'json',
                data:{
                    phone:localStorage.getItem('phone')
                },
                success:function (resp) {
                    // alert(1)
                }
            })
        }
    }
};
var forget={
    template:'#forget',
    data(){
        return{
            forget_pho:'',
            forget_y:false
        }
    },
    methods:{
        yan(){
            var self = this;
            reqwest({
                url:'http://api.zgtxcj.com/mobile/judgephone/',
                method:'post',
                type:'json',
                data:{
                    phone:self.forget_pho,
                },
                success(resp){
                    if(resp['result']!='ok'){
                        self.showCustomPopup()
                    }else {
                        localStorage.setItem('thisphone',self.forget_pho);
                        self.forget_y=true;
                        self.next();
                    }
                }
            })
        },
        next(){
            // var self = this;
            if(this.forget_y){
                this.$router.forward({path:'/message'})
            }else {
                this.showCustomPopup1()
            }
        },
        goNow(){
            this.$router.back({path:'/login'})
        },
        showCustomPopup() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">该手机号不是注册用户</p>', options);
            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
        showCustomPopup1() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">请填写手机号</p>', options);
            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
    }
};
var message={
    template:'#message',
    data(){
        return{
            pho:'',
            code:''
        }
    },
    methods:{
        getPho(){
            var one=localStorage.getItem('thisphone');
            this.pho = one.substring(0,3);
        },
        goNow(){
            this.$router.back({path:'/forget'})
        },
        getDuan(){
            var self=this;
            reqwest({
                url:'http://api.zgtxcj.com/mobile/phone_sms/',
                method:'get',
                type:'json',
                data:{
                    phone:localStorage.getItem('thisphone'),
                    type: 'findpass',
                },
                success(resp){
                    // console.log(resp)
                    if(resp){
                        var duan=120;
                        setTime();
                        function setTime() {
                            if(duan<1){
                                $('.message_cli.forget_bl').removeAttr("disabled");
                                $('.message_cli.forget_bl').val('获取验证码');
                                duan=120
                                return
                            }else {
                                $('.message_cli.forget_bl').attr("disabled",'disabled');
                                $('.message_cli.forget_bl').val(duan+'s');
                                duan--;
                            }
                            setTimeout(function () {
                                setTime()
                            },1000);
                        }
                    }else {
                        self.showCustomPopup2()
                    }
                }
            })
        },
        puan(){
            if(this.code==''){
                this.showCustomPopup1()
            }else {
                this.yanDuan();
            }
        },
        yanDuan(){
            var self = this;
            reqwest({
                url:'http://api.zgtxcj.com/mobile/phone_sms/',
                method:'post',
                type:'json',
                data:{
                    phone:localStorage.getItem('thisphone'),
                    code:self.code
                },
                success(resp){
                    if(resp){
                        $('.message_cli.forget_bl').removeAttr("disabled");
                        $('.message_cli.forget_bl').val('获取验证码');
                        self.$router.forward({path:'/setPass'})
                    }else {
                        self.code='';
                        self.showCustomPopup()
                    }
                }
            })
        },
        showCustomPopup1() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">验证码不能为空</p>', options);
            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
        showCustomPopup() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">验证码错误</p>', options);
            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
        showCustomPopup2() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">发送失败,请稍候重试</p>', options);
            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
    },
    beforeMount:function(){
        this.getPho();
    }
};
var setPass={
    template:'#setPass',
    data(){
        return{
            pass:''
        }
    },
    methods:{
        confirm(){
            var self = this;
            reqwest({
                url:'http://api.zgtxcj.com/mobile/findpass/',
                method:'post',
                type:'json',
                data:{
                    phone:localStorage.getItem('thisphone'),
                    password:self.pass,
                },
                success(resp){
                    if(resp['result']=='ok'){
                        self.showCustomPopup()
                    }else {
                        self.showCustomPopup1()
                    }
                }
            })
        },
        tiao(){
            this.$nextTick(function () {
                this.$router.back({path:'/login'})
            })
        },
        goNow(){
            this.$router.back({path:'/message'})
        },
        showCustomPopup() {
            $toast.show('修改成功', 1500).then(() => {
                console.log('toast hide')
            });
            this.tiao()
        },
        showCustomPopup1() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">修改失败</p>', options);
            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
    }
};
var sign={
    template:'#sign',
    data(){
        return{
            tel:'',
            nicheng:'',
            passwd:'',
            passwd1:'',
            stel:'',
        }
    },
    methods:{
        showCustomPopup() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">手机号错误</p>', options);
            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
        showCustomPopup1() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">密码不一致或密码错误</p>', options)

            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
        showCustomPopup2() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">请阅读并同意网站须知</p>', options);
            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
        showCustomPopup3() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">注册成功</p>', options);
            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
        clic(){
            var display=$('.re_check img').css('display');
            // $('.re_check').click(function(){
                if(display=='none'){
                    $('.re_check img').show();
                }else {
                    $('.re_check img').hide();
                }
            // });
        },
        postZ(){
            var self=this;
            var display=$('.re_check img').css('display');
                if(!(/^1[3|4|5|7|8][0-9]\d{4,8}$/.test(self.tel))){
                    self.showCustomPopup()
                }else {
                    if(self.passwd1==self.passwd&&self.passwd1.length>6&&self.passwd1.length<12){
                        if(display=='none'){
                            self.showCustomPopup2()
                        }else {
                          if(self.stel==''||self.stel==null){
                            reqwest({
                                   url:'http://api.zgtxcj.com/mobile/register/',
                                 // url:'http://fapp.zgtxcj.com:88/mobile/register/',
                                  method:'post',
                                  type:'json',
                                  data:{
                                      phone: self.tel,
                                      password:self.passwd1,
                                      // Number:'',
                                  },
                                  success(resp){
                                      if(resp['result']=='ok'){
                                          self.showCustomPopup3();
                                          self.$router.back('/login')
                                      }else {
                                          alert(resp.message)
                                      }
                                  }
                              });
                          }else{
                            reqwest({
                                  url:'http://api.zgtxcj.com/mobile/register/',
                                  //url:'http://fapp.zgtxcj.com:88/mobile/register/',
                                  method:'post',
                                  type:'json',
                                  data:{
                                      phone: self.tel,
                                      password:self.passwd1,
                                      rphone:self.stel,
                                      // Number:'',
                                  },
                                  success(resp){
                                      if(resp['result']=='ok'){
                                          self.showCustomPopup3();
                                          self.$router.back('/login')
                                      }else {
                                          alert(resp.message)
                                      }
                                  }
                              });
                          }
                        }
                    }else {
                        self.showCustomPopup1()
                    }
                }
            // }
        },
        goNow(){
            // this.clic();
            this.$router.back({path:'/login'})
        }
    }
};
var zuanshi={
    template:'#zuanshi',
    data(){
        return{
            myUrl:'http://api.zgtxcj.com/txcjapi/',
            zuanAll:[],
        }
    },
    methods:{
        goNow(){
            this.$router.back({path:'/my'})
        },
        toTijiao(){
            this.$router.forward({path:'/tijiao'})
        },
        zuan:function(){
            var self=this;
            reqwest({
                url:self.myUrl+'indiamonds/?tag=diamonds',
                // url:'http://192.168.0.154:4000/txcjapi/indiamonds/?tag=diamonds',
                method:'get',
                type:'json',
                success(data){
                    for( var o in data){
                        if(data[o]['d_state']==2){
                            self.zuanAll.push(data[o]);
                        }
                    }
                    for(var p in self.zuanAll){
                          if(self.zuanAll[p]['d_image'].indexOf('|')!=-1){
                                self.zuanAll[p]['d_image']=self.zuanAll[p]['d_image'].split('|')[0]
                          }
                    }
                }
            })
        },
        yanLogin(){
            var self = this;
            var ua = window.navigator.userAgent.toLowerCase();
            if(ua.match(/MicroMessenger/i) == 'micromessenger'){
                self.puanTag="wx";
                localStorage.setItem('puanTag','wx')
            }else{
                self.puanTag="google";
                localStorage.setItem('puanTag','google')
            }
            reqwest({
                url:'http://api.zgtxcj.com/straapi/login/',
                method:'get',
                type:'json',
                data:{
                    username:localStorage.getItem('phone'),
                    token:localStorage.getItem('token'),
                    tag:self.puanTag
                },
                success:function(resp){
                    if(resp!=false&&resp!=true){
                        window.localStorage.setItem('token',resp);
                    }else {
                        self.$router.forward({path:'/login'})
                        //window.location.href='http://wx.zgtxcj.com/gongzhonghao/index.html#/login';
                    }
                }
            })
        }
    },
    beforeMount(){
        this.yanLogin();
        this.zuan();
    }
};
var tijiao={
    template:'#tijiao',
    data(){
        return{
            myUrl:'http://api.zgtxcj.com/txcjapi/',
            did:localStorage.getItem('did'),
            zuanx:[],
            zuanCh:[],
            zengCh:[]
        }
    },
    methods:{
        getXiang(){
            var self = this;
            reqwest({
                url:self.myUrl+'indiamonds/?tag=diamonds&id='+self.did,
                method:'get',
                type:'json',
                success(resp){
                      if(resp['d_image'].indexOf('|')!=-1){
                                resp['d_image']=resp['d_image'].split('|')[0]
                          }
                    self.zuanx=resp;
                    self.getChan();
                }
            })
        },
        getChan(){
            var self = this;
            reqwest({
                url: self.myUrl + 'indiamonds/?tag=diapro&id=' + self.did,
                method: 'get',
                type: 'json',
                success(resp){
                    for (var t in resp){
                        if(resp[t]['dp_tag']==1){
                            resp[t]['product']['p_image']=resp[t]['product']['p_image'].split('|')[0];
                            self.zuanCh.push(resp[t]);
                        }
                        if(resp[t]['dp_tag']==3){
                            self.zengCh.push(resp[t])
                        }
                    }
                }
            })
        },
        putImg(){
            if($(".open_checkbox span img").length==0||$(".open_checkbox span img").length==null){
                $(".open_checkbox").find('span').append('<img src="../img/yes.png">')
            }else {
                $(".open_checkbox span img").remove();
            }
        },
        showCustomPopup() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">请阅读并同意风险提示及免责声明</p>', options)

            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
        toPay(){
            if($(".open_checkbox span img").length==0||$(".open_checkbox span img").length==null){
                this.showCustomPopup()
            }else {
                this.$router.forward({path:'/pay'})
            }
        },
        goNow(){
            this.$router.back({path:'zuanshi'})
        },
        toXieyi(){
            this.$router.forward({path:'/xieyi'})
        },
    },
    beforeMount(){
        this.getXiang();
    }
};
var pay={
    template:'#pay',
    data(){
        return{
            myUrl:'http://api.zgtxcj.com/txcjapi/',
            did:localStorage.getItem('did'),
            zuanx:[],
            zuan_now:'',
            zuanCh:[],
            yue:'',
            type:'',
            yid:'',
            bian:'',
            money:'',
            mandt:'',
            zuanNum:'',
            yuemon:''
        }
    },
    methods:{
        zuanTi:function(){
            var self = this;
            console.log(self.zuanx);
            if (self.zuan_now<self.zuanx['d_edition']){
                self.zuan_now='';
                $('.ding_time_kxm').eq(0).addClass('ding_time_kxn');
                $('.ding_time_kr').html('￥'+self.zuanx['d_editprice']+'元')
            }else {
                // console.log(this.zuan_now)
                $('.ding_time_kxm.ding_time_kxn').removeClass('ding_time_kxn');
                $('.ding_time_kr').html('￥'+self.zuanx['d_orderprice']*$(".ding_time_inp").val()+'元')
            }
        },
        yestu(){
            $('.ding_zeng_line').click(function () {
                $('.imgre').remove();
                $(this).find('.ding_zeng_qu').append('<img class="imgre" src="../img/yes.png"/>')
            })
        },
        getXi(){
            var self = this;
            reqwest({
                url:self.myUrl+'indiamonds/?tag=diamonds&id='+self.did,
                method:'get',
                type:'json',
                success(resp){
                    if(resp['d_time']==30){
                        resp['d_time']='月'
                    }else if(resp['d_time']==90){
                        resp['d_time']='季'
                    }else if(resp['d_time']=='365'){
                        resp['d_time']='年'
                    }
                     if(resp['d_image'].indexOf('|')!=-1){
                                resp['d_image']=resp['d_image'].split('|')[0]
                          }
                    self.yuemon=resp['d_price'];
                    self.zuanx=resp;
                    self.getChan();
                }
            })
        },
        getChan(){
            var self = this;
            reqwest({
                url: self.myUrl + 'indiamonds/?tag=diapro&id=' + self.did,
                method: 'get',
                type: 'json',
                success(resp){
                    for (var t in resp){
                        resp[t]['product']['p_image']=resp[t]['product']['p_image'].split('|')[0];
                        if(resp[t]['dp_tag']==3){
                            self.zuanCh.push(resp[t])
                        }
                    }
                    self.kaicli();
                }
            })
        },
        kaicli(){
            this.$nextTick(function(){
                var self=this;
                $('.ding_time_tong').removeAttr('disabled');
                $('.ding_time_tong1').removeAttr('disabled');
                $('.ding_time_kzs').click(function () {
                    var index=$(this).index();
                    $('.ding_time_kzs').removeClass('ding_time_kzf').eq(index-1).addClass('ding_time_kzf')
                });
                self.yestu();
                self.numClick();
                localStorage.setItem('mat',$('.ding_mon').html());
                var ua = window.navigator.userAgent.toLowerCase();
                if(ua.match(/MicroMessenger/i) == 'micromessenger'){
                    $('.ding_time_tong1.click_txt').hide();
                    $('.ding_time_tong.click_txt').show();
                    $('.ding_time_tong').click(function(){
                        var ua = window.navigator.userAgent.toLowerCase();
                        self.type=$('.ding_time_kzf').attr('fid');
                        if($('.ding_time_inp').val()==''){
                            self.yue=  $('.ding_time_kxn').html() ;
                        }else {
                            self.yue=$('.ding_time_inp').val();
                        }
                        window.localStorage.setItem('yue',self.yue);
                        window.localStorage.setItem('pname',self.zuanx.d_name);
                        self.gift=$('.imgre').parent('.ding_zeng_qu').parent('.ding_zeng_line').attr('yid');
                        if(self.gift==undefined){
                            self.gift=0
                        };
                        window.localStorage.setItem('gift',self.gift);
                        self.money=$('.ding_time_kr').html();
                        localStorage.setItem('money',self.money);
                        if(self.zuanCh.length==0){
                            if(self.type==5){
                                self.$router.forward({path:'/zhifu'})
                            }else{
                                window.localStorage.setItem('pname',self.zuanx.d_name);
                                self.mandt=$('.ding_mon').html();
                                $('.o_zengid').val($('.imgre').parent('.ding_zeng_qu').parent('.ding_zeng_line').attr('yid'));
                                $('.o_money').val($('.ding_time_kr').html());
                                $('.o_useid').val(localStorage.getItem('uid'));
                                $('.o_time').val(self.yue);
                                $('.o_price').val(self.zuanx['d_price']);
                            }
                        }else {
                            if($('.imgre').length>0){
                                if(self.type==5){
                                    self.$router.forward({path:'/zhifu'})
                                }else{
                                    window.localStorage.setItem('pname',self.zuanx.d_name);
                                    self.mandt=$('.ding_mon').html();
                                    $('.o_zengid').val($('.imgre').parent('.ding_zeng_qu').parent('.ding_zeng_line').attr('yid'));
                                    $('.o_money').val($('.ding_time_kr').html());
                                    $('.o_useid').val(localStorage.getItem('uid'));
                                    $('.o_time').val(self.yue);
                                    $('.o_price').val(self.zuanx['d_price']);
                                }
                            }else {
                                self.showCustomPopup();
                                return false;
                            };
                        }
                    });
                }else{
                    $('.ding_time_tong.click_txt').hide();
                    $('.ding_time_tong1.click_txt').show();
                    $('.ding_time_tong1').click(function(){
                        var ua = window.navigator.userAgent.toLowerCase();
                        self.type=$('.ding_time_kzf').attr('fid');
                        if($('.ding_time_inp').val()==''){
                            self.yue=  $('.ding_time_kxn').html() ;
                        }else {
                            self.yue=$('.ding_time_inp').val();
                        }
                        window.localStorage.setItem('yue',self.yue);
                        window.localStorage.setItem('pname',self.zuanx.d_name);
                        self.gift=$('.imgre').parent('.ding_zeng_qu').parent('.ding_zeng_line').attr('yid');
                        if(self.gift==undefined){
                            self.gift=0
                        };
                        window.localStorage.setItem('gift',self.gift);
                        self.money=$('.ding_time_kr').html();
                        localStorage.setItem('money',self.money);
                        if(self.zuanCh.length==0){
                            if(self.type==5){
                                self.$router.forward({path:'/zhifu'})
                            }else{
                                reqwest({
                                    url:'http://api.zgtxcj.com/txcjapi/placeorder/',
                                    method:'post',
                                    type:'json',
                                    data:{
                                        uid:localStorage.getItem('uid'),
                                        type:6,
                                        num:self.yue,
                                        gift:self.gift,
                                        did:self.zuanx['d_id']
                                    },
                                    success:function (resp) {
                                        self.id_order=resp;
                                        // function get_client_ip() {
                                        //     $cip = "unknown";
                                        //     if($_SERVER['REMOTE_ADDR']){
                                        //         $cip = $_SERVER['REMOTE_ADDR']
                                        //     }else if(getenv("REMOTE_ADDR")){
                                        //         $cip = getenv("REMOTE_ADDR");
                                        //     }
                                        //     return $ip
                                        // }
                                        // +'&ip='+get_client_ip()
                                        reqwest({
                                            url:'http://api.zgtxcj.com/mobile/wxpay/?o_id='+self.id_order+'&d_name='+self.zuanx.d_name,
                                            method:'get',
                                            type:'json',
                                            success(resp){
                                                // alert(resp);
                                                window.location.href=resp
                                                    //+'&redirect_url=http%3a%2f%2fwx.zgtxcj.com%2fgongzhonghao%2fzhifusuc.html&Position=xz'
                                                //window.location.href=resp+'&redirect_url=http%3A%2F%2Fxz.zgtxcj.com%2Fgongzhonghao%2Findex.html%23%2FcallBack'
                                            }
                                        })
                                    }
                                });
                                window.localStorage.setItem('pname',self.zuanx.d_name);
                                self.mandt=$('.ding_mon').html();
                                $('.o_zengid').val($('.imgre').parent('.ding_zeng_qu').parent('.ding_zeng_line').attr('yid'));
                                $('.o_money').val($('.ding_time_kr').html());
                                $('.o_useid').val(localStorage.getItem('uid'));
                                $('.o_time').val(self.yue);
                                $('.o_price').val(self.zuanx['d_price']);
                            }
                        }else {
                            if($('.imgre').length>0){
                                if(self.type==5){
                                    self.$router.forward({path:'/zhifu'})
                                }else{
                                    reqwest({
                                        url:'http://api.zgtxcj.com/txcjapi/placeorder/',
                                        method:'post',
                                        type:'json',
                                        data:{
                                            uid:localStorage.getItem('uid'),
                                            type:6,
                                            num:self.yue,
                                            gift:self.gift,
                                            did:self.zuanx['d_id'],
                                        },
                                        success:function (resp) {
                                            self.id_order=resp;
                                            // function get_client_ip() {
                                            //     $cip = "unknown";
                                            //     if($_SERVER['REMOTE_ADDR']){
                                            //         $cip = $_SERVER['REMOTE_ADDR']
                                            //     }else if(getenv("REMOTE_ADDR")){
                                            //         $cip = getenv("REMOTE_ADDR");
                                            //     }
                                            //     return $ip
                                            // }+'&ip='+get_client_ip()
                                            reqwest({
                                                url:'http://api.zgtxcj.com/mobile/wxpay/?o_id='+self.id_order+'&d_name='+self.zuanx.d_name,
                                                method:'get',
                                                type:'json',
                                                success(resp){
                                                    window.location.href=resp
                                                        //+'&redirect_url=http%3a%2f%2fwx.zgtxcj.com%2fgongzhonghao%2fzhifusuc.html&Position=xz'
                                                }
                                            })
                                        }
                                    });
                                    window.localStorage.setItem('pname',self.zuanx.d_name);
                                    self.mandt=$('.ding_mon').html();
                                    $('.o_zengid').val($('.imgre').parent('.ding_zeng_qu').parent('.ding_zeng_line').attr('yid'));
                                    $('.o_money').val($('.ding_time_kr').html());
                                    $('.o_useid').val(localStorage.getItem('uid'));
                                    $('.o_time').val(self.yue);
                                    $('.o_price').val(self.zuanx['d_price']);
                                }
                            }else {
                                self.showCustomPopup();
                                return false;
                            };
                        }
                    });
                }

            })
        },
        numClick(){
            var self=this;
            $('.ding_time_dis').click(function () {
                self.zuan_now='';
                var index=$(this).index();
                $('.ding_time_kxm.ding_time_kxn').removeClass('ding_time_kxn');
                $(this).find('.ding_time_kxm').addClass('ding_time_kxn');
                self.zuanNum=$('.ding_time_kxn').html();
                $('.ding_time_kr').html('￥'+self.yuemon*self.zuanNum+'元')
            })
        },
        goNow(){
            this.$router.back({path:'/tijiao'})
        },
        showCustomPopup() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">请选择赠送内容</p>', options)

            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
        showCustomPopup9() {
            let options = {
                effect: 'scale',
                title: '',
                buttons: [
                    {text: '确定'},
                    {text: '取消'},
                ]
            };

            let popup = $popup.fromTemplate('<p style="margin-bottom: 0; text-align: center;">出错</p>', options)

            popup.show().then((buttonIndex) => {
                // console.log(buttonIndex)
            })
        },
    },
    beforeMount(){
        this.getXi();
    }
};
var zhifu={
    template:'#zhifu',
    data(){
        return{
            mon:'',
            dingdan:'',
            mat:'',
            pname:'',
            yue:''
        }
    },
    methods:{
        getDdbh(){
            var self=this;
            // console.log(localStorage.getItem('gift'));
            reqwest({
                url:'http://api.zgtxcj.com/txcjapi/placeorder/',
                method:'post',
                type:'json',
                data:{
                    uid:localStorage.getItem('uid'),
                    did:localStorage.getItem('did'),
                    gift:localStorage.getItem('gift'),
                    type:5,
                    num:localStorage.getItem('yue')
                },
                success(resp){
                    // console.log(resp)
                    self.dingdan=resp;
                    self.getzhifu()
                }
            })
        },
        getzhifu(){
            this.mat=localStorage.getItem('mat');
            this.mon=localStorage.getItem('money');
            this.pname=localStorage.getItem('pname');
            this.yue=localStorage.getItem('yue');
            console.log(this.yue)
        },
        goNow(){
            this.$router.back({path:'/pay'})
        }
    },
    beforeMount(){
        this.getDdbh()
    }
};
var zhifusuc={
    template:'#zhifusuc',
    methods:{
        goNow(){
            this.$router.back({path:'/zhifu'})
        },
        toIndex(){
            this.$router.forward({path:'/'})
        }
    }
};
var Tabs = {
    template: '#tabs',
    data() {
        return {
            allTab:[],
            pengTab:[],
            paidTab:[]
        }
    },
    methods: {
        getTabs(){
            var self=this;
            reqwest({
                url:'http://api.zgtxcj.com/mobile/userorder/',
                method:'post',
                type:'json',
                data:{
                    uid:localStorage.getItem('uid'),
                    status:3,
                    tag:'detail',
                    pag:1
                },
                success(resp){
                    for (var l in resp['data']){
                        // console.log(resp)
                         if(resp['data'][l]['image'].indexOf('|')!=-1){
                                resp['data'][l]['image']=resp['data'][l]['image'].split('|')[0];
                          }
                        //resp['data'][l]['image']=resp['data'][l]['image'].split('|')[0];
                        // if(resp['data'][l]['status']==1){
                            self.allTab.push(resp['data'][l]);
                        // }
                    }
                    self.getPending()
                }
            })
        },
        getPending(){
            var self=this;
            reqwest({
                url:'http://api.zgtxcj.com/mobile/userorder/',
                method:'post',
                type:'json',
                data:{
                    uid: localStorage.getItem('uid'),
                    status:1,
                    tag:'detail',
                    pag:'1'
                },
                success(resp){
                    for (var l in resp['data']){
                        if(resp['data'][l]['image'].indexOf('|')!=-1){
                                resp['data'][l]['image']=resp['data'][l]['image'].split('|')[0];
                          }
                        // if(resp['data'][l]['status']==1){
                            self.pengTab.push(resp['data'][l]);
                        // }
                    }
                    self.getPaid()
                }
            })
        },
        getPaid(){
            var self=this;
            reqwest({
                url:'http://api.zgtxcj.com/mobile/userorder/',
                method:'post',
                type:'json',
                data:{
                    uid: localStorage.getItem('uid'),
                    status:2,
                    tag:'detail',
                    pag:'1'
                },
                success(resp){
                    for (var l in resp['data']){
                        if(resp['data'][l]['image'].indexOf('|')!=-1){
                                resp['data'][l]['image']=resp['data'][l]['image'].split('|')[0];
                          }
                        // if(resp['data'][l]['status']==1){
                            self.paidTab.push(resp['data'][l]);
                        // }
                    }
                    self.getDong()
                }
            })
        },
        getDong(){
            this.$nextTick(function () {
                $('.xuan_li').click(function () {
                    var index=$(this).index();
                    $('.xuan_li').removeClass('xuan_active').eq(index).addClass('xuan_active');
                    if(index==0){
                        $('.zuan_all').css('display','block');
                        $('.zuan_unpaid').css('display','none');
                        $('.zuan_paid').css('display','none');
                    }else if(index==1){
                        $('.zuan_all').css('display','none');
                        $('.zuan_unpaid').css('display','block');
                        $('.zuan_paid').css('display','none');
                    }else if(index==2){
                        $('.zuan_all').css('display','none');
                        $('.zuan_unpaid').css('display','none');
                        $('.zuan_paid').css('display','block');
                    }
                })
            })  
        },
        getunPaid(){
            this.$router.forward({path:'/unPaid'})
        },
        getTabid(){
            this.$router.forward({path:'/Order'})
        },
        goNow(){
            this.$router.back({path:'/my'})
        }
    },
    beforeMount(){
        this.getTabs();
    }
};
var Order = {
    template: '#Order',
    data() {
        return {
            tabId:localStorage.getItem('tabId'),
            tabXiang:[],
        }
    },
    methods: {
        goNow(){
            this.$router.back({path:'/Tabs'})
        },
        getTab(){
            var self=this;
            reqwest({
                url:'http://api.zgtxcj.com/mobile/speorder/',
                method:'post',
                type:'json',
                data:{
                    uid:localStorage.getItem('uid'),
                    od_id:localStorage.getItem('tabId')
                },
                success(resp){
                    resp['data']['time']=resp['data']['time'].replace(/T/,' ');
                     if(resp['data']['image'].indexOf('|')!=-1){
                           resp['data']['image']=resp['data']['image'].split('|')[0];
                     }
                    //resp['data']['image']=resp['data']['image'].split('|')[0];
                    self.tabXiang=resp['data'];
                }
            })
        }
    },
    beforeMount(){
        this.getTab()
    }
};
var unPaid = {
    template: '#unPaid',
    data() {
        return {
            dingID:localStorage.getItem('tabId'),
            uid:localStorage.getItem('uid'),
            ding:[],
            zuan:[],
            d_id:'',
            zeng:[]
        }
    },
    methods: {
        goNow(){
            this.$router.back({path:'/tabs'})
        },
        getZuan(){
            var self = this;
            reqwest({
                url:'http://api.zgtxcj.com/txcjapi/indiamonds/?tag=diamonds',
                method:'get',
                type:'json',
                success:function(resp){
                    self.zuan=resp;
                    self.getDing();
                }
            })
        },
        getDing(){
            var self= this;
            reqwest({
                url:'http://api.zgtxcj.com/mobile/speorder/',
                method:'post',
                type:'json',
                data:{
                    uid:self.uid,
                    od_id:self.dingID
                },
                success:function (resp) {
                    for(var k in self.zuan){
                        if(self.zuan[k]['d_name']==resp['data']['name']){
                            resp['data']['cate']=self.zuan[k].d_cate;
                            resp['data']['d_id']=self.zuan[k].d_id;
                            self.d_id=self.zuan[k].d_id;
                            resp['data']['uid']=self.uid
                        }
                    }
                    if(resp['result']=='ok'){
                        resp['data']['time']=resp['data']['time'].replace(/T/,' ');
                         if(resp['data']['image'].indexOf('|')!=-1){
                                resp['data']['image']=resp['data']['image'].split('|')[0];
                          }
                        self.ding=resp['data'];
                    }else {
                        console.log('请检查参数')
                    }
                    // console.log(self.ding)
                    self.getZeng();
                }
            })
        },
        getZeng(){
            var self = this;
            reqwest({
                url: 'http://api.zgtxcj.com/txcjapi/indiamonds/?tag=diapro&id=' + self.d_id,
                method: 'get',
                type: 'json',
                success(resp){
                    for (var t in resp){
                        resp[t]['product']['p_image']=resp[t]['product']['p_image'].split('|')[0];
                        if(resp[t]['dp_tag']==3){
                            self.zeng.push(resp[t])
                        }
                    }
                    self.cli()
                }
            })
        },
        cli(){
            var self=this;
            this.$nextTick(function () {
                $('.ding_zeng_line').click(function () {
                    $('.imgre').remove();
                    $(this).find('.ding_zeng_qu').append('<img class="imgre" src="../img/yes.png"/>')
                })
                $('.ding_time_kzs').click(function () {
                    var index=$(this).index();
                    $('.ding_time_kzs').removeClass('ding_time_kzf').eq(index-1).addClass('ding_time_kzf')
                });
                var type=$('.ding_time_kzf').attr('fid');
                $('.click_l').click(function () {
                    if(self.zeng.length==0){
                        if(type==5){
                            self.$router.forward({path:'/zhifu'})
                        }else {

                        }
                    }else {
                        if($('.imgre').length>0){
                            if(self.type==5){
                                self.$router.forward({path:'/zhifu'})
                            }else {
                                $('.o_zengid').val($('.imgre').parent('.ding_zeng_qu').parent('.ding_zeng_line').attr('yid'));
                            }
                        }
                    }
                })
            })
        }
    },
    beforeMount:function () {
        this.getZuan()
    }
};
var channel = {
    template: '#channel',
    data() {
        return {
            userid:localStorage.getItem('uid'),
            qudao:'',
            phone:localStorage.getItem('phone')
        }
    },
    methods: {
        goNow(){
            this.$router.back({path:'/my'})
        },
        toList(){
            this.$router.forward({path:'/channelList'})
        },
        getMe(){
            var self = this;
            reqwest({
                url: 'http://api.zgtxcj.com/txcjapi/user_mess/?id=' + self.userid,
                method: 'get',
                type: 'json',
                success(resp){
                    self.qudao=resp['U_Number'];
                }
            })
        },
        getTok(){
            var  self  =  this;
           var ua = window.navigator.userAgent.toLowerCase();
            if(ua.match(/MicroMessenger/i) == 'micromessenger'){
                self.puanTag="wx";
                localStorage.setItem('puanTag','wx')
            }else{
                self.puanTag="google";
                localStorage.setItem('puanTag','google')
            }
            reqwest({
                url:'http://api.zgtxcj.com/straapi/login/',
                method:'get',
                type:'json',
                data:{
                    username:localStorage.getItem('phone'),
                    token:localStorage.getItem('token'),
                    tag:self.puanTag
                },
                success:function(resp){
                    if(resp!=false&&resp!=true){
                        window.localStorage.setItem('token',resp);
                        self.getMe()
                    }else {
                        self.$router.forward({path:'/login'})
                        //window.location.href='http://wx.zgtxcj.com/gongzhonghao/index.html#/login';
                    }
                }
            })
        },
        pan(){
            //history.go(0) 
            var tok=localStorage.getItem('token');
            if(tok==''||tok==null){
               window.location.href='http://wx.zgtxcj.com/gongzhonghao/xz-index.html#/login';
            }else {
                this.$router.forward({path:'/channel'})
            }
        }
    },
    beforeMount(){
        this.getTok();
        //this.pan()
    }
};
var channelList={
    template:'#channelList',
    data(){
        return{
            user:[]
        }
    },
    methods:{
        goNow(){
            this.$router.back({path:'/channel'})
        },
        getYong(){
            var self = this;
            reqwest({
                url:'http://api.zgtxcj.com/mobile/userrecommend/',
                method:'get',
                type:'json',
                data:{
                    uid:localStorage.getItem('uid')
                },
                success(resp){
                    self.user=resp;
                }
            })
        }
    },
    beforeMount(){
        this.getYong()
    }
};

var routes = [
    { path: '/', component: now },
    { path: '/my', component: my },
    { path: '/Reference', component: Reference },
    { path: '/Notice', component: Notice },
    { path: '/infor', component: infor },
    { path: '/xieyi', component: xieyi },
    { path: '/zuanguan', component: zuanguan },
    { path: '/myzi', component: myzi },
    { path: '/change', component: change },
    { path: '/tui', component: tui },
    { path: '/login', component: login },
    { path: '/forget', component: forget },
    { path: '/message', component: message },
    { path: '/setPass', component: setPass },
    { path: '/sign', component: sign },
    { path: '/zuanshi', component: zuanshi },
    { path: '/tijiao', component: tijiao },
    { path: '/pay', component: pay },
    { path: '/zhifu', component: zhifu },
    { path: '/zhifusuc', component: zhifusuc },
    { path: '/tabs', component: Tabs },
    { path: '/Order', component: Order },
    { path: '/unPaid', component: unPaid },
     { path: '/channel', component: channel },
    { path: '/channelList', component: channelList },
];

//Vonic.app.setConfig('pushMethod', 'replace');

Vue.use(Vonic.app, {
    routes: routes
});